//
//  FeedbackOnTheIssueQAViewController.swift
//  FrameProduct
//
//  Created by delegate on 2025/10/22.
//

import UIKit

class FeedbackOnTheIssueQAViewController: BaseViewController {
    var dataSourceArr: [String] = ["·连接问题:经常连接不上,连接无法上网等", "·充值问题:购买后没有显示套餐等", "·产品问题:用得不爽,我有建议", "·其他问题"]
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNavi()
        setupUI()
    }
    private func setupNavi() {
        navigationItem.title = "问题反馈"
    }
    private func setupUI() {
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.right.bottom.equalToSuperview()
        }
    }
    //=================================================================
    //                            lazy
    //=================================================================
    // MARK: - lazy
    private lazy var tableView: UITableView = {
        let tableView = UITableView(frame: .zero, style: .grouped)
        tableView.separatorStyle = .none
        tableView.delegate = self
        tableView.dataSource = self
        tableView.registerCellClass(MineFeedbackOnTheIssueQATableViewCell.self)
        tableView.backgroundColor = .clear
        return tableView
    }()
}

extension FeedbackOnTheIssueQAViewController: UITableViewDelegate, UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        1
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        dataSourceArr.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(MineFeedbackOnTheIssueQATableViewCell.self, for: indexPath)
        cell.titleStr = dataSourceArr[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        tableView.rowHeight
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        45
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let headerView = UIView(frame: CGRect(x: 0, y: 0, width: ScreenSize.width, height: 45))
        let titleLabel = UILabel(frame: CGRect(x: 13, y: 0, width: ScreenSize.width - 26, height: 45))
        titleLabel.text = "请选择您想要反馈的问题点"
        titleLabel.textColor = .lxs.hex("#A6A6A6")
        titleLabel.font = .lxs.font(size: 14)
        headerView.addSubview(titleLabel)
        return headerView
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = MineFeedbackOnTheIssueQADetailViewController()
        
        navigationController?.pushViewController(vc, animated: true)
    }
}
